<template>
    <q-page padding>
        <div class="text-h5 q-mb-md">重置密码请联系管理员 QQ/微信:89326054</div>
        <q-btn label="返回登录" color="primary" @click="backToLogin" />

        <!-- <q-form @submit="onSubmitReset">
            <q-input v-model="uname" label="用户名" :rules="[val => !!val || '请输入用户名']" class="q-mb-md" />
            <q-input v-model="agency" label="分会" :rules="[val => !!val || '请输入分会名称']" class="q-mb-md" />
            <q-input v-model="newPassword" label="新密码" type="password" :rules="[
                val => !!val || '请输入新密码',
                val => val.length >= 6 || '密码长度至少6位'
            ]" class="q-mb-md" />
            <q-input v-model="confirmPassword" label="确认密码" type="password" :rules="[
                val => !!val || '请确认密码',
                val => val === newPassword || '两次输入的密码不一致'
            ]" class="q-mb-lg" />

            <div class="row q-gutter-sm">
                <q-btn label="重置密码" type="submit" color="primary" />
                <q-btn label="返回登录" flat color="grey" @click="backToLogin" />
            </div>
        </q-form> -->
    </q-page>
</template>

<script>
import { resetPassword } from 'src/js/api' // 需要在api中实现这个方法

export default {
    data() {
        return {
            uname: '',
            agency: '',
            newPassword: '',
            confirmPassword: ''
        }
    },
    methods: {
        async onSubmitReset() {
            try {
                const res = await resetPassword({
                    uname: this.uname,
                    agency: this.agency,
                    newPassword: this.newPassword
                })

                if (res) {
                    this.$q.notify({
                        type: 'positive',
                        message: '密码重置成功'
                    })
                    this.backToLogin()
                }
            } catch (error) {
                this.$q.notify({
                    type: 'negative',
                    message: '密码重置失败：' + error.message
                })
            }
        },

        backToLogin() {
            this.$router.push({ name: 'LoginPage' })
        }
    }
}
</script>